﻿@using System.IO;
@inherits _BaseView

<MudRTLProvider RightToLeft="@SharedLayoutSettings.IsRTL">
    <EditForm OnValidSubmit="OnSubmit" Model="SubmitUserViewModel">
        <DataAnnotationsValidator />
        <MudDialog>
            <DialogContent>
                @if (!IsLoaded)
                {
                    <FormOverlay />
                }
                else
                {
                    <MudCard Class="mt-2">
                        <MudPaper Elevation="25">
                            <MudToolBar Dense>
                                <MudText Color="Color.Primary">
                                    @DashboardResource.StringUser
                                </MudText>
                                <MudSpacer />
                                <MudIconButton Disabled="@IsProcessing" ButtonType="ButtonType.Submit" Icon="@Icons.Material.Filled.Save" Color="Color.Tertiary" title="@DashboardResource.StringCreate">
                                    @if (IsProcessing)
                                    {
                                        <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="ms-n1" />
                                        <MudText Class="ms-2">@DashboardResource.StringProcessing</MudText>
                                    }
                                    else
                                    {
                                        <MudIcon Icon="@Icons.Material.Filled.Save" Color="Color.Surface" Class="mx-1" />
                                        <MudText>@DashboardResource.StringSave</MudText>
                                    }
                                </MudIconButton>
                                <MudIconButton OnClick="Close" Icon="@Icons.Material.Filled.Close" Color="Color.Error" title="@DashboardResource.StringCancel" />
                            </MudToolBar>
                        </MudPaper>
                        <MudDivider DividerType="DividerType.FullWidth" />
                        <MudCardContent>
                            <MudTabs ActivePanelIndexChanged="(TabIndex) => TabIndexChanged(TabIndex)" @ref="Tab" Elevation="2" Rounded ApplyEffectsToContainer PanelClass="pa-2">
                                <MudTabPanel Text="@DashboardResource.StringPersonalInformation">
                                    <MudGrid>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.UserName" Variant="Variant.Outlined"
                                                          For="@(() => SubmitUserViewModel.UserName)" Label="@DashboardResource.StringUserName"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Person" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.Password" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Password"
                                                          For="@(() => SubmitUserViewModel.Password)" Label="@DashboardResource.StringPassword" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.PersonalCode" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Bolt"
                                                          For="@(() => SubmitUserViewModel.PersonalCode)" Label="@DashboardResource.StringPersonalCode" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.FirstName" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Fingerprint"
                                                          For="@(() => SubmitUserViewModel.FirstName)" Label="@DashboardResource.StringFirstName" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.LastName" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Group"
                                                          For="@(() => SubmitUserViewModel.LastName)" Label="@DashboardResource.StringLastName" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.FatherName" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.AssignmentInd"
                                                          For="@(() => SubmitUserViewModel.FatherName)" Label="@DashboardResource.StringFatherName" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.NationalCode" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.PersonalInjury"
                                                          For="@(() => SubmitUserViewModel.NationalCode)" Label="@DashboardResource.StringNationalCode" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudTextField @bind-Value="SubmitUserViewModel.PhoneNumber" Variant="Variant.Outlined"
                                                          Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Smartphone"
                                                          For="@(() => SubmitUserViewModel.PhoneNumber)" Label="@DashboardResource.StringPhoneNumber" />
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudSelect T="DropDownGenderViewModel" Label="@DashboardResource.StringGender" Variant="Variant.Outlined"
                                                       Clearable @bind-Value="SubmitUserViewModel.Gender"
                                                       For="@(() => SubmitUserViewModel.Gender)">
                                                @foreach (var item in Genders)
                                                {
                                                    <MudSelectItem Value="@item">@item.Sex</MudSelectItem>
                                                }
                                            </MudSelect>
                                        </MudItem>
                                        <MudItem md="3">
                                            <MudSelect T="DropDownRoleViewModel" Label="@DashboardResource.StringRole" Variant="Variant.Outlined"
                                                       Clearable @bind-Value="SubmitUserViewModel.Role"
                                                       For="@(() => SubmitUserViewModel.Role)">
                                                @foreach (var item in Roles)
                                                {
                                                    <MudSelectItem Value="@item">@item.Name</MudSelectItem>
                                                }
                                            </MudSelect>
                                        </MudItem>
                                        <MudItem md="6">

                                        </MudItem>
                                        <MudItem md="6">
                                            <MudSelect Label="@DashboardResource.StringPost" Variant="Variant.Outlined"
                                                       Clearable MultiSelection="true" SelectAll="true"
                                                       SelectAllText="@DashboardResource.StringSelectAll"
                                                       MultiSelectionTextFunc="@(new Func<List<string>, string>(GetDepartmentMultiSelectionText))"
                                                       @bind-SelectedValues="SubmitUserViewModel.DepartmentValues"
                                                       @bind-Value="SubmitUserViewModel.IdDepartment"
                                                       For="@(() => SubmitUserViewModel.IdDepartment)">
                                                @foreach (var item in Departments)
                                                {
                                                    <MudSelectItem Value="@item?.Id">@item?.Title</MudSelectItem>
                                                }
                                            </MudSelect>
                                        </MudItem>
                                        <MudItem md="6">
                                            <MudSelect Label="@DashboardResource.StringGroup" Variant="Variant.Outlined"
                                                       Clearable MultiSelection="true" SelectAll="true"
                                                       SelectAllText="@DashboardResource.StringSelectAll"
                                                       MultiSelectionTextFunc="@(new Func<List<string>, string>(GetGroupMultiSelectionText))"
                                                       @bind-SelectedValues="SubmitUserViewModel.GroupValues"
                                                       @bind-Value="SubmitUserViewModel.IdGroup"
                                                       For="@(() => SubmitUserViewModel.IdGroup)">
                                                @foreach (var item in Groups)
                                                {
                                                    <MudSelectItem Value="@item?.Id">@item?.Title</MudSelectItem>
                                                }
                                            </MudSelect>
                                        </MudItem>
                                    </MudGrid>
                                </MudTabPanel>
                                <MudTabPanel Text="@DashboardResource.StringAvatar">
                                    <MudGrid>
                                        <MudItem md="12">
                                            <MudAvatar Style="height:150px; width:150px; display: block;margin-left: auto;margin-right: auto;">
                                                <MudImage Src="@("data:image/png;base64," + Avatar)" />
                                            </MudAvatar>
                                        </MudItem>
                                        <MudItem md="12">
                                            <MudStack Justify="@Justify.Center" Row="true" Class="ma-5">
                                                <InputFile id="fileInput" OnChange="OnInputFileChange" hidden accept=".jpg, .jpeg, .png" />
                                                <MudButton HtmlTag="label"
                                                           Variant="Variant.Filled"
                                                           Color="Color.Primary"
                                                           StartIcon="@Icons.Material.Filled.CloudUpload" for="fileInput">
                                                    @DashboardResource.StringUploadFiles
                                                </MudButton>
                                                <MudButton Color="Color.Error" OnClick="Delete" Variant="Variant.Filled">
                                                    <MudIcon Icon="@Icons.Material.Filled.DeleteForever" Color="Color.Surface" Class="mx-1" />
                                                    @DashboardResource.StringDelete
                                                </MudButton>
                                            </MudStack>
                                        </MudItem>
                                    </MudGrid>
                                </MudTabPanel>
                            </MudTabs>
                        </MudCardContent>
                    </MudCard>
                }
            </DialogContent>
        </MudDialog>
    </EditForm>
</MudRTLProvider>

@code {

    [CascadingParameter]
    public MudDialogInstance MudDialog { get; set; }

    private void Close() => MudDialog.Close();

    // *****************************************************

    [Parameter]
    public string Id { get; set; }

    private SubmitUserViewModel SubmitUserViewModel = new();

    // ***************************************************

    protected MudTabs Tab;

    // ***************************************************

    private void HandleValidationRequested(object sender, ValidationRequestedEventArgs e)
    {
        ValidationMessageStore?.Clear();

        if (string.IsNullOrEmpty(SubmitUserViewModel.UserName) || string.IsNullOrEmpty(SubmitUserViewModel.Password))
        {
            HasValidationError = true;
            Tab.ActivatePanel(0);
            //ValidationMessageStore?.Add(() => SubmitUserServiceTypeViewModel.IdUserServiceTypeGroup, string.Format(DashboardResource.ValidationRequired, AppResource.StringRequest));
        }
    }

    private async Task TabIndexChanged(int? TabIndex = null)
    {
        if (TabIndex == 0 && HasValidationError == true)
        {
            await Task.Delay(300);
            await Dom.QuerySelector("#btn").OnClickAsync();
            HasValidationError = false;
        }
    }

    protected override async Task OnInitializedAsync()
    {
        IsLoaded = false;

        try
        {
            EditContext = new EditContext(SubmitUserViewModel);
            EditContext.OnValidationRequested += HandleValidationRequested;
            EditContext.OnFieldChanged += (s, e) => ValidationMessageStore?.Clear(e.FieldIdentifier);
            ValidationMessageStore = new(EditContext);

            await GetGendersAsync();
            await GetRolesAsync();
            Departments = await GetDepartmentsAsync("");
            Groups = await GetGroupsAsync("");

            if (!string.IsNullOrEmpty(Id) && Id != "0")
            {
                //await PermissionService.CheckAuthorizeAsync(PermissionDefaultValue.User.Edit, PermissionAuthenticationState,
                //    AuthorizationService, Navigation);

                var Callback = await Http.GetFromJsonAsync<CallbackResult<GetUserViewModel>>($"api/Users/GetUserById/{Id}");

                if (Callback.Data != null)
                {
                    SubmitUserViewModel.Id = Callback.Data.Id;
                    SubmitUserViewModel.UserName = Callback.Data.UserName;
                    SubmitUserViewModel.Password = Callback.Data.Password;
                    SubmitUserViewModel.PersonalCode = Callback.Data.PersonalCode;
                    SubmitUserViewModel.FirstName = Callback.Data.FirstName;
                    SubmitUserViewModel.LastName = Callback.Data.LastName;
                    SubmitUserViewModel.FatherName = Callback.Data.FatherName;
                    SubmitUserViewModel.NationalCode = Callback.Data.NationalCode;
                    SubmitUserViewModel.Avatar = Callback.Data.Avatar;
                    SubmitUserViewModel.PhoneNumber = Callback.Data.PhoneNumber;

                    if (Callback.Data.Gender != null)
                    {
                        SubmitUserViewModel.Gender =
                            Genders.FirstOrDefault(x => x.Id == Callback.Data.Gender.Id) ?? null;
                    }
                    if (Callback.Data.Role != null)
                    {
                        SubmitUserViewModel.Role =
                            Roles.FirstOrDefault(x => x.Id == Callback.Data.Role.Id) ?? null;
                    }

                    Avatar = Convert.ToBase64String(SubmitUserViewModel.Avatar);

                    await GetUserDepartmentsAsync(true);
                    await GetUserGroupsAsync();

                    StateHasChanged();
                }
            }
            else
            {
                //await PermissionService.CheckAuthorizeAsync(PermissionDefaultValue.User.Create, PermissionAuthenticationState,
                //      AuthorizationService, Navigation);
            }
        }
        catch (Exception ex)
        {
            Snackbar.Add($"{DashboardResource.StringError} : " + ex.Message, Severity.Error);
        }

        IsLoaded = true;
    }

    private async Task OnSubmit()
    {
        if (IsProcessing)
            return;
        IsProcessing = true;

        try
        {
            if (UplaodImage == null)
            {
                UplaodImage = Convert.FromBase64String(Avatar);
            }
            SubmitUserViewModel.Avatar = UplaodImage;

            if (Id == "0")
            {
                var PostResult = await Http.PostAsJsonAsync("api/Authentications/create", SubmitUserViewModel.TrimStringAndCheckPersianSpecialLetter());
                if (PostResult.IsSuccessStatusCode)
                {
                    var JsonResult = await PostResult.Content.ReadFromJsonAsync<CallbackResult<ApplicationUser>>();
                    if (JsonResult.Data != null)
                    {
                        Snackbar.Add(JsonResult.SuccessMessage ?? DashboardResource.MessageSavedSuccessfully, Severity.Success);
                        MudDialog.Close(DialogResult.Ok(SubmitUserViewModel));
                    }
                    else
                    {
                        Snackbar.Add(MessageHandler.ErrorHandler(JsonResult.Error), Severity.Error);
                    }
                }
                else
                {
                    Snackbar.Add(PostResult.Content.ReadAsStringAsync().Result, Severity.Error);
                }
            }
            else
            {
                var PutResult = await Http.PutAsJsonAsync("api/Authentications/Edit", SubmitUserViewModel.TrimStringAndCheckPersianSpecialLetter());
                if (PutResult.IsSuccessStatusCode)
                {
                    var JsonResult = await PutResult.Content.ReadFromJsonAsync<CallbackResult<ApplicationUser>>();
                    if (JsonResult.Data != null)
                    {
                        Snackbar.Add(JsonResult.SuccessMessage ?? DashboardResource.MessageSavedSuccessfully, Severity.Success);
                        MudDialog.Close(DialogResult.Ok(SubmitUserViewModel));
                    }
                    else
                    {
                        Snackbar.Add(MessageHandler.ErrorHandler(JsonResult.Error), Severity.Error);
                    }
                }
                else
                {
                    Snackbar.Add(PutResult.Content.ReadAsStringAsync().Result, Severity.Error);
                }
            }
        }
        catch (Exception ex)
        {
            Snackbar.Add($"{DashboardResource.StringError} : " + ex.Message, Severity.Error);
        }
        IsProcessing = false;
    }

    #region - Combo & Dropdown -

    private List<DropDownGenderViewModel> Genders = new();

    private List<DropDownRoleViewModel> Roles = new();

    private async Task GetGendersAsync()
    {
        var Callback = await Http.GetFromJsonAsync<CallbackResult<List<Gender>>>($"api/Users/GetGenders");
        if (Callback.Data != null)
        {
            Genders = Callback.Data.Select(x => new DropDownGenderViewModel
                {
                    Id = x.Id,
                    Sex = x.Sex,
                }).ToList();
        }
        else
        {
            Snackbar.Add(Callback.Error.ToString(), Severity.Error);
        }
    }

    private async Task GetRolesAsync()
    {
        var Callback = await Http.GetFromJsonAsync<CallbackResult<List<GetRoleViewModel>>>($"api/Roles/GetRole");
        if (Callback.Data != null)
        {
            Roles = Callback.Data.Select(x => new DropDownRoleViewModel
                {
                    Id = x.Id,
                    Name = x.Name,
                }).ToList();
        }
        else
        {
            Snackbar.Add(Callback.Error.ToString(), Severity.Error);
        }
    }

    // **************************************

    private IEnumerable<DropDownDepartmentViewModel> Departments = new List<DropDownDepartmentViewModel>();

    private async Task<IEnumerable<DropDownDepartmentViewModel>> GetDepartmentsAsync(string value)
    {
        List<DropDownDepartmentViewModel> Parents = new();
        var Callback = await Http.GetFromJsonAsync<CallbackResult<List<DropDownDepartmentViewModel>>>($"api/Departments/GetDropDownDepartments?value={value}");
        if (Callback.Data != null)
        {
            Parents = Callback.Data.Select(x => new DropDownDepartmentViewModel
                {
                    Id = x.Id,
                    IdParent = x.IdParent,
                    Title = x.Title,
                }).ToList();
        }
        else
        {
            Snackbar.Add(Callback.Error.ToString(), Severity.Error);
        }
        return Parents;
    }

    private async Task GetUserDepartmentsAsync(bool IsPersonal)
    {
        var Callback = await Http.GetFromJsonAsync<CallbackResult<List<int?>>>($"api/Departments/GetIdUserDepartments?IdUser={SubmitUserViewModel.Id}");
        if (Callback.Data != null)
        {
            SubmitUserViewModel.DepartmentValues = Callback.Data;
        }
        else
        {
            Snackbar.Add(Callback.Error.ToString(), Severity.Error);
        }
    }

    private string GetDepartmentMultiSelectionText(List<string> SelectedValues)
    {
        var SelectedTexts = Departments.Where(i => SelectedValues.Any(a => i.Id == int.Parse(a))).Select(s => s.Title);

        return $"{string.Join(" , ", SelectedTexts)}";
    }

    // **************************************

    private IEnumerable<DropDownGroupViewModel> Groups = new List<DropDownGroupViewModel>();

    private string GetGroupMultiSelectionText(List<string> SelectedValues)
    {
        var SelectedTexts = Groups.Where(i => SelectedValues.Any(a => i.Id == int.Parse(a))).Select(s => s.Title);

        return $"{string.Join(" , ", SelectedTexts)}";
    }

    private async Task<IEnumerable<DropDownGroupViewModel>> GetGroupsAsync(string value)
    {
        List<DropDownGroupViewModel> Parents = new();
        var Callback = await Http.GetFromJsonAsync<CallbackResult<List<DropDownGroupViewModel>>>($"api/Groups/GetDropDownGroups?value={value}");
        if (Callback.Data != null)
        {
            Parents = Callback.Data.Select(x => new DropDownGroupViewModel
                {
                    Id = x.Id,
                    Title = x.Title,
                }).ToList();
        }
        else
        {
            Snackbar.Add(Callback.Error.ToString(), Severity.Error);
        }
        return Parents;
    }

    private async Task GetUserGroupsAsync()
    {
        var Callback = await Http.GetFromJsonAsync<CallbackResult<List<int?>>>($"api/Groups/GetIdUserGroups?IdUser={SubmitUserViewModel.Id}");
        if (Callback.Data != null)
        {
            SubmitUserViewModel.GroupValues = Callback.Data;
        }
        else
        {
            Snackbar.Add(Callback.Error.ToString(), Severity.Error);
        }
    }

    #endregion

    #region - File Management -

    private IBrowserFile file;

    private byte[] UplaodImage = null;
    private string Avatar = "iVBORw0KGgoAAAANSUhEUgAAAOAAAADgCAMAAAAt85rTAAAAe1BMVEX29vYAAAD39/f6+vro6Oh5eXnf39/z8/Ps7OwpKSnAwMCxsb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3TYOUDsr8qUmvK0K5ZDZf7KB/6WiKDVI5aU7Zx9Rie78dAteiMpTPazztv7nB4XbvT3EunSmup/YabBn0o77iMQ1ry+161aDsoRrbar1d9n+mSjdHyOplRgG+mlMarAcSlH9os3tz9lkaFUlDRZRme+etN3UXNFynEw2IyWZypdfDy9AMTKDyEvqTs9mm+wGE2qHkHHE6fYe2AbthMkDSON2FWD9sIq0KG/e+3NwA27gCpfbjJN+iNeh6evzU6/gLZvDZUSWpqaNVy4mno5MakM0nXyZ98cpMDiU+nBJtnDDxTMjmkymjQaPa4IpDeWUEFN3D2J+U5SyyZDoqVleosKLbeqtYlut9u75FtUVgmp85wn51XcY4y1cnMWFcSl+nVZ7F3gxJiDMBtH7cgzgID85JEnnoaHlyDmHQyOU8YfK5ADZ9N4VjXDcuwpyzOBsrNQ+L2HXbMjMzBsfnDNu2wc2nac1U33z9ndVpzDlYmRUgO5AFAf7aRY1fA/in6H+A/3b6H+C/nQij2/6L9A8uo/6oyaU9/gAAAABJRU5ErkJggg==";

    private async Task OnInputFileChange(InputFileChangeEventArgs e)
    {
        file = e.File;

        if (file.Size > 0)
        {
            if (file.Size < FileDefaultValue.MaxImageSize)
            {
                var fs1 = file.OpenReadStream(FileDefaultValue.MaxImageSize);
                var memoryStream = new MemoryStream();
                await fs1.CopyToAsync(memoryStream);

                UplaodImage = memoryStream.ToArray();

                Avatar = Convert.ToBase64String(UplaodImage);
            }
            else
            {
                Snackbar.Add($"بارگذاری نشد {file.Name} فایل", Severity.Error);
            }
        }
    }

    private void Delete()
    {
        Avatar = "iVBORw0KGgoAAAANSUhEUgAAAOAAAADgCAMAAAAt85rTAAAAe1BMVEX29vYAAAD39/f6+vro6Oh5eXnf39/z8/Ps7OwpKSnAwMCxsbHDw8NycnLX19fS0tK3t7dWVlYaGho8PDxBQUGjo6OTk5OcnJyJiYlGRkZPT08zMzPJyclpaWkiIiKHh4deXl4PDw8XFxcwMDBbW1soKChkZGSXl5dubm712n4JAAAUCElEQVR4n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3tz9lkaFUlDRZRme+etN3UXNFynEw2IyWZypdfDy9AMTKDyEvqTs9mm+wGE2qHkHHE6fYe2AbthMkDSON2FWD9sIq0KG/e+3NwA27gCpfbjJN+iNeh6evzU6/gLZvDZUSWpqaNVy4mno5MakM0nXyZ98cpMDiU+nBJtnDDxTMjmkymjQaPa4IpDeWUEFN3D2J+U5SyyZDoqVleosKLbeqtYlut9u75FtUVgmp85wn51XcY4y1cnMWFcSl+nVZ7F3gxJiDMBtH7cgzgID85JEnnoaHlyDmHQyOU8YfK5ADZ9N4VjXDcuwpyzOBsrNQ+L2HXbMjMzBsfnDNu2wc2nac1U33z9ndVpzDlYmRUgO5AFAf7aRY1fA/in6H+A/3b6H+C/nQij2/6L9A8uo/6oyaU9/gAAAABJRU5ErkJggg==";

        SubmitUserViewModel.Avatar = Convert.FromBase64String(Avatar);
    }

    #endregion

    new public void Dispose()
    {
        if (EditContext is not null)
        {
            EditContext.OnValidationRequested -= HandleValidationRequested;
        }
    }

}
